//营销活动办理信息录入页面创建事件  
$('#sterminus_index').live("pagecreate", function() {  
     //返回  
       $(this).delegate('#btnbackIndex', 'click', function(e) {  
           window.location.href = "windex.do?reqCode=indexInit";  
         });  
         
     //动态绑定值到代办商  
       $.ajax({   
           type:"post",   
           url:"windex.do?reqCode=mobileagentDataLoad",   
           data:"",   
           success:function(data) {  
           var map =  eval("("+data+")");   
               $.each(map,function(key,value){  
                   var code = value.code;  
                   //alert(code);  
                   var codedesc=value.codedesc;  
                     
               $("<option value="+code+">"+codedesc+"</option>").appendTo("#agent");   
                    }   
               );    
            }   
           });   
         
     //保存  
       $("#btnsubmit").bind("click", function() {  
           var phonemodels = document.getElementById('phonemodels').value;  
           var imeinumber = document.getElementById('imeinumber').value;  
           var agent = document.getElementById('agent').value;  
           var cmobile = document.getElementById('cmobile').value;  
           var cname=document.getElementById('cname').value;  
           var ccardnum=document.getElementById('ccardnum').value;  
           var cbirth=document.getElementById('cbirth').value;  
           var sex=document.getElementById('sex').value;  
           var chomeaddr=document.getElementById('chomeaddr').value;  
             
           if (phonemodels == "" || imeinumber == "" || cmobile == "" || cname == "" || ccardnum == "" || cbirth == "" || chomeaddr == "") {  
               alert("请填写完整数据！");  
               return;  
           }  
  
           if (!checkRQ(cbirth)) {  
               alert("生日的日期格式输入有误,请核对!格式为：yyyy-mm-dd 如：2013-10-10");  
               document.getElementById('cbirth').focus();  
               return;  
           }  
            
           $.ajax({  
  
               type: "POST",  
               url: "windex.do?reqCode=saveTerminusByMobilePhone",  
               data: $("form#terminusform").serialize(),  
               success: function(d){  
               var r= $.parseJSON(d);  
               var msg=r.msg;  
                 
               if(r.success==true)  
                   alert(msg);  
                   $('#phonemodels').val('');  
                   $('#imeinumber').val('');  
                   $('#cmobile').val('');  
                   $('#cname').val('');  
                   $('#ccardnum').val('');  
                   $('#cbirth').val('');  
                   $('#chomeaddr').val('');  
            },  
               error:function(d){  
                   var r= $.parseJSON(d);  
                   var msg=r.data;  
                   alert(msg);  
                    //alert("网络无法连接服务器");  
                }  
             
           });  
            
         });  
       //取消  
       $("#btncanel").bind("click", function() {  
           $('#phonemodels').val('');  
           $('#imeinumber').val('');  
           $('#cmobile').val('');  
           $('#cname').val('');  
           $('#ccardnum').val('');  
           $('#cbirth').val('');  
           $('#chomeaddr').val('');  
         });  
        
});

